package com.huawei.appgallery.appcomment.ui.usercomment;

import android.content.Context;
import android.text.SpannableString;
import android.text.SpannableStringBuilder;
import android.text.TextUtils;
import android.text.style.ForegroundColorSpan;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
import android.widget.TextView;
import com.huawei.appgallery.appcomment.impl.bean.UserReplyInfoCardBean;
import com.huawei.appgallery.appcomment.impl.bean.UserReplyInfoCardBean.ReviewReply.RepliedComment;
import com.huawei.appgallery.appcomment.ui.view.FoldTextView;
import com.huawei.appgallery.appcomment.ui.view.FoldTextView.b;
import com.huawei.appgallery.appcomment.ui.view.FoldTextView.e;
import com.huawei.appgallery.foundation.card.base.card.BaseDistCard;
import com.huawei.appgallery.foundation.ui.framework.cardkit.bean.CardBean;
import huawei.widget.HwTextView;
import java.util.Locale;
import o.azb;
import o.bcg;
import o.bcg.a;
import o.bcg.c;
import o.bcg.h;
import o.bei;
import o.ber;
import o.cea;
import o.cgy;
import o.cgz;
import o.dof;
import o.eqx;

public class UserReplyInfoCard extends BaseDistCard implements OnClickListener, e, b {
    private View ʻ;
    private FoldTextView ʻॱ;
    private LinearLayout ʼ;
    private ImageView ʽ;
    private LinearLayout ˊॱ;
    private ImageView ˋ;
    private HwTextView ˋˋ;
    private TextView ˋॱ;
    private UserReplyInfoCardBean ˋᐝ;
    private HwTextView ˌ;
    private LinearLayout ˍ;
    private ImageView ˎˎ;
    private HwTextView ˎˏ;
    private TextView ˏॱ;
    private ImageView ͺ;
    private LinearLayout ͺॱ;
    private TextView ॱˊ;
    private TextView ॱˋ;
    private LinearLayout ॱˎ;
    private View ॱॱ;
    private TextView ॱᐝ;
    private View ᐝ;
    private FrameLayout ᐝॱ;

    public UserReplyInfoCard(Context context) {
        super(context);
    }

    public cgz ˏ(View view) {
        ˏ((TextView) view.findViewById(bcg.e.ˎˏ));
        ˊ(view.findViewById(bcg.e.ˋॱ));
        ˊ((LinearLayout) view.findViewById(bcg.e.ॱˋ));
        ˋ((TextView) view.findViewById(bcg.e.ॱᐝ));
        ˎ((LinearLayout) view.findViewById(bcg.e.ˈ));
        ˎ((TextView) view.findViewById(bcg.e.ʾ));
        ˋ((LinearLayout) view.findViewById(bcg.e.ͺॱ));
        this.ˋ = (ImageView) view.findViewById(bcg.e.ʿ);
        this.ʽ = (ImageView) view.findViewById(bcg.e.ʻॱ);
        this.ᐝॱ = (FrameLayout) view.findViewById(bcg.e.ـ);
        this.ͺ = (ImageView) view.findViewById(bcg.e.ﹶ);
        this.ˏॱ = (TextView) view.findViewById(bcg.e.ˋˋ);
        this.ॱᐝ = (TextView) view.findViewById(bcg.e.ˎˏ);
        this.ʻॱ = (FoldTextView) view.findViewById(bcg.e.ॱʼ);
        this.ˋˋ = (HwTextView) view.findViewById(bcg.e.ﾟॱ);
        this.ᐝ = view.findViewById(bcg.e.ᐝʽ);
        this.ʻ = view.findViewById(bcg.e.ˊॱ);
        this.ʻॱ.setOnContentChangedListener(this, this.ˋˋ);
        this.ʻॱ.setOnMaxLineListener(this, this.ˋˋ);
        this.ˋˋ.setOnClickListener(this);
        this.ॱˋ = (TextView) view.findViewById(bcg.e.ꜞ);
        this.ˎˎ = (ImageView) view.findViewById(bcg.e.ॱॱ);
        this.ˌ = (HwTextView) view.findViewById(bcg.e.ʻ);
        this.ˍ = (LinearLayout) view.findViewById(bcg.e.ˉ);
        this.ˎˏ = (HwTextView) view.findViewById(bcg.e.ˊˋ);
        ˏ((LinearLayout) view.findViewById(bcg.e.ॱˊ));
        ber.ˎ(this.ॱॱ);
        ʽ(view);
        return this;
    }

    public TextView ˏ() {
        return this.ॱᐝ;
    }

    public UserReplyInfoCard ˏ(TextView textView) {
        this.ॱᐝ = textView;
        return this;
    }

    public View ॱ() {
        return this.ॱॱ;
    }

    private void ˊ(View view) {
        this.ॱॱ = view;
    }

    public LinearLayout ˎ() {
        return this.ʼ;
    }

    private void ˊ(LinearLayout linearLayout) {
        this.ʼ = linearLayout;
    }

    private void ˋ(TextView textView) {
        this.ˋॱ = textView;
    }

    public LinearLayout ˋ() {
        return this.ˊॱ;
    }

    private void ˎ(LinearLayout linearLayout) {
        this.ˊॱ = linearLayout;
    }

    public LinearLayout ˊ() {
        return this.ͺॱ;
    }

    public UserReplyInfoCard ˏ(LinearLayout linearLayout) {
        this.ͺॱ = linearLayout;
        return this;
    }

    public FrameLayout ᐝ() {
        return this.ᐝॱ;
    }

    private void ˎ(TextView textView) {
        this.ॱˊ = textView;
    }

    private void ˋ(LinearLayout linearLayout) {
        this.ॱˎ = linearLayout;
    }

    public LinearLayout ॱॱ() {
        return this.ॱˎ;
    }

    public void ˏ(CardBean cardBean) {
        super.ˏ(cardBean);
        if (cardBean instanceof UserReplyInfoCardBean) {
            this.ˋᐝ = (UserReplyInfoCardBean) cardBean;
            ˊ(this.ˋᐝ);
        }
    }

    private void ˊ(UserReplyInfoCardBean userReplyInfoCardBean) {
        ॱ(userReplyInfoCardBean);
        ˏ(userReplyInfoCardBean);
        ˎ(userReplyInfoCardBean);
    }

    private void ॱ(UserReplyInfoCardBean userReplyInfoCardBean) {
        int i = 0;
        if (this.ᐝ != null) {
            this.ᐝ.setVisibility(ˊᐝ() ? 0 : 4);
        }
        if (this.ʻ != null) {
            LayoutParams layoutParams = (LayoutParams) this.ʻ.getLayoutParams();
            if (!userReplyInfoCardBean.ॱˍ()) {
                i = (int) this.ʼॱ.getResources().getDimension(bcg.b.ˏ);
            }
            layoutParams.topMargin = i;
            this.ʻ.setLayoutParams(layoutParams);
        }
    }

    private void ˎ(UserReplyInfoCardBean userReplyInfoCardBean) {
        RepliedComment ʼ = userReplyInfoCardBean.ˏ().ʼ();
        String ʼ2 = ʼ.ʼ();
        String ˎ = ʼ.ˎ();
        if (TextUtils.isEmpty(ʼ2) || TextUtils.isEmpty(ˎ)) {
            this.ॱॱ.setVisibility(8);
            return;
        }
        this.ॱॱ.setVisibility(0);
        if (this.ॱˋ != null) {
            this.ॱˋ.setText(ˊ(ˎ, ʼ2));
        }
    }

    private void ˏ(UserReplyInfoCardBean userReplyInfoCardBean) {
        ॱॱ(userReplyInfoCardBean);
        ॱ(this.ॱᐝ, bei.ॱ(this.ʼॱ, userReplyInfoCardBean.ˏ().ʻ()));
        ॱ(this.ˏॱ, userReplyInfoCardBean.ˏ().ˎ());
        ˊ(this.ͺ, userReplyInfoCardBean.ˏ().ˏ());
        if (userReplyInfoCardBean.ˏ().ॱˊ() == 1) {
            this.ˋ.setBackgroundResource(c.ˎ);
        } else {
            this.ˋ.setBackgroundResource(c.ˏ);
        }
        CharSequence string = this.ॱˊ.getContext().getString(h.ㆍ);
        if (userReplyInfoCardBean.ˏ().ˋॱ() != 0) {
            ॱ(this.ॱˊ, cgy.ˎ((double) userReplyInfoCardBean.ˏ().ˋॱ()));
            this.ˋ.setContentDescription(string);
        } else {
            this.ˋ.setContentDescription(null);
            this.ॱˊ.setText(string);
        }
        if (this.ʽ != null) {
            this.ʽ.setContentDescription(null);
        }
        if (userReplyInfoCardBean.ˊ() != 0) {
            this.ॱˎ.setVisibility(8);
            azb.ˋ(this.ʼ, 0, this.ʼॱ.getResources().getDimensionPixelSize(bcg.b.ʼ));
        } else {
            this.ॱˎ.setVisibility(0);
        }
        ˋ(userReplyInfoCardBean);
        if (!dof.ॱ(userReplyInfoCardBean.ॱˌ())) {
            eqx.ˏ(this.ˎˎ, userReplyInfoCardBean.ॱˌ(), "app_default_icon");
        }
        ॱ(this.ˌ, userReplyInfoCardBean.ॱ());
        ʼ(userReplyInfoCardBean);
    }

    private void ˋ(UserReplyInfoCardBean userReplyInfoCardBean) {
        if (this.ˍ != null && this.ˎˏ != null) {
            switch (userReplyInfoCardBean.ˏ().ॱॱ()) {
                case 3:
                    this.ˍ.setVisibility(0);
                    this.ˎˏ.setText(this.ʼॱ.getResources().getString(h.י));
                    return;
                case 4:
                    this.ˍ.setVisibility(0);
                    this.ˎˏ.setText(this.ʼॱ.getResources().getString(h.ॱॱ));
                    return;
                default:
                    this.ˍ.setVisibility(8);
                    return;
            }
        }
    }

    private void ॱॱ(UserReplyInfoCardBean userReplyInfoCardBean) {
        if (this.ʻॱ != null && this.ᐝॱ != null) {
            Object ˊॱ = userReplyInfoCardBean.ˏ().ˊॱ();
            Object ʽ = userReplyInfoCardBean.ˏ().ʽ();
            if (TextUtils.isEmpty(ˊॱ) || TextUtils.isEmpty(ʽ)) {
                this.ᐝॱ.setVisibility(8);
                return;
            }
            this.ᐝॱ.setVisibility(0);
            this.ʻॱ.setContent(ˋ(ˊॱ, ʽ), userReplyInfoCardBean.ˎ(), ber.ॱ(this.ʻॱ));
        }
    }

    private SpannableStringBuilder ˊ(String str, String str2) {
        SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(new SpannableString(this.ʼॱ.getString(h.ᐧॱ, new Object[]{str, str2})));
        spannableStringBuilder.setSpan(new ForegroundColorSpan(this.ʼॱ.getResources().getColor(a.ˊ)), 0, str.length(), 33);
        return spannableStringBuilder;
    }

    private SpannableStringBuilder ˋ(String str, String str2) {
        Object format = String.format(Locale.ENGLISH, this.ʼॱ.getResources().getString(h.ॱʾ), new Object[]{str, str2});
        SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(format);
        spannableStringBuilder.setSpan(new ForegroundColorSpan(this.ʼॱ.getResources().getColor(a.ˏ)), 0, format.lastIndexOf(str2), 33);
        return spannableStringBuilder;
    }

    private void ʼ(final UserReplyInfoCardBean userReplyInfoCardBean) {
        if (this.ॱॱ.getWidth() == 0) {
            this.ॱॱ.post(new Runnable(this) {
                final /* synthetic */ UserReplyInfoCard ˏ;

                public void run() {
                    this.ˏ.ʼ(userReplyInfoCardBean);
                }
            });
            return;
        }
        int width = (((this.ॱॱ.getWidth() - (this.ˋ.getWidth() * 2)) - (this.ʼॱ.getResources().getDimensionPixelSize(bcg.b.ˏॱ) * 2)) - (this.ʼॱ.getResources().getDimensionPixelSize(bcg.b.ͺ) * 2)) / 2;
        this.ˋॱ.setMaxWidth(width);
        this.ॱˊ.setMaxWidth(width);
    }

    private void ॱ(TextView textView, String str) {
        if (TextUtils.isEmpty(str)) {
            textView.setVisibility(8);
            return;
        }
        textView.setVisibility(0);
        textView.setText(str);
    }

    private void ˊ(ImageView imageView, String str) {
        if (TextUtils.isEmpty(str)) {
            imageView.setImageResource(c.ᐝॱ);
            imageView.setTag("");
        } else if (!str.equals((String) imageView.getTag())) {
            imageView.setTag(str);
            cea.ˏ(imageView, str, "head_default_icon");
        }
    }

    public void onClick(View view) {
        if (this.ʻॱ != null && this.ˋᐝ != null) {
            this.ʻॱ.ॱ();
            this.ˋᐝ.ˏ(this.ʻॱ.ˏ());
        }
    }

    public void ˊ(boolean z, HwTextView hwTextView) {
        if (hwTextView == null) {
            return;
        }
        if (z) {
            hwTextView.setText(hwTextView.getContext().getString(h.ॱꜞ));
        } else {
            hwTextView.setText(hwTextView.getContext().getString(h.ॱﾞ));
        }
    }

    public void ॱ(boolean z, HwTextView hwTextView) {
        if (hwTextView == null) {
            return;
        }
        if (z) {
            hwTextView.setVisibility(0);
        } else {
            hwTextView.setVisibility(8);
        }
    }
}
